<?php

declare(strict_types=1);

namespace App\Nats\Publish;

use Hyperf\Di\Annotation\Inject;
use Hyperf\Nats\Driver\DriverInterface;

class ProxyNats
{
    /**
     * @Inject
     * @var NatsPublish
     */
    protected $proxynats;

    /**
     * @Inject
     * @var DriverInterface
     */
    protected $nats;

    public function publish($data, $subject = 'hyperf.demo')
    {
        $res = $this->nats->publish($subject, $data);
        return $res;
    }

    public function sync($data, $subject = 'hyperf.demo')
    {
        /** @var Message $message */
        $message = $this->nats->requestSync($subject, $data);
        return $message->getBody();
        
        
    }

    // public function __call($name, $argv)
    // {
    //     return $this->proxynats->$name(...$argv);
    // }
}